<?php

class Application_Model_DbTable_Pairs extends Zend_Db_Table_Abstract {

    protected $_name = 'pairs';
	
    public function getPair($wId,$rId){
        $row = $this->fetchRow("wordId='".$wId."' AND replyId =  '".$rId."'");
        return $row;
	}
	
	public function getWord($rId){
		$rows = $this->fetchAll("replyId=".$rId);
		return $rows;
	}
		
	public function createPair($wId,$rId,$num){
		$row = $this->createRow();
		$row->wordId = $wId;
		$row->replyId = $rId;
		$row->ct = $num;
		$row->save();
		return $row;
	}
	
	public function updatePair($wId,$rId,$num){
		$row = $this->getPair($wId,$rId);
		$count = $row->ct;
		$count = $count + $num;
		$row->ct = $count;
		$row->save();
		return $row;
	}
}
